
//
//  UIButton+AYExtension.m
//  AYExtension
//
//  Created by AY on 16/8/2.
//  Copyright © 2016年 Alex. All rights reserved.
//

#import "UIButton+AYExtension.h"

@implementation UIButton (AYExtension)

- (instancetype)set {
    return self;
}

+ (instancetype)button {
    return [self buttonWithType:UIButtonTypeCustom];
}

- (UIButton *(^)(NSString *))normalTitle {
    return ^(NSString *title){
        [self setTitle:title forState:UIControlStateNormal];
        return self;
    };
}

- (UIButton *(^)(NSString *))selectedTitle {
    return ^(NSString *title){
        [self setTitle:title forState:UIControlStateSelected];
        return self;
    };
}

- (UIButton *(^)(NSString *))highlightTitle {
    return ^(NSString *title){
        [self setTitle:title forState:UIControlStateNormal];
        return self;
    };
}

- (UIButton *(^)(UIImage *))normalImage {
    return ^(UIImage *image){
        [self setImage:image forState:UIControlStateNormal];
        return self;
    };
}
- (UIButton *(^)(UIImage *))normalBackgroundImage {
    return ^(UIImage *image){
        [self setBackgroundImage:image forState:UIControlStateNormal];
        return self;
    };
}
- (UIButton *(^)(UIImage *))selectedImage {
    return ^(UIImage *image){
        [self setImage:image forState:UIControlStateSelected];
        return self;
    };
}

- (UIButton *(^)(UIImage *))selectedBackgroundImage {
    return ^(UIImage *image){
        [self setBackgroundImage:image forState:UIControlStateSelected];
        return self;
    };
}

- (UIButton *(^)(UIImage *))highlightedImage {
    return ^(UIImage *image){
        [self setImage:image forState:UIControlStateHighlighted];
        return self;
    };
}

- (UIButton *(^)(UIImage *))highlightedBackgroundImage {
    return ^(UIImage *image){
        [self setBackgroundImage:image forState:UIControlStateHighlighted];
        return self;
    };
}

@end
